import sys
import os
# 获取 user 目录的绝对路径
user_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'customize')
# 将 user 目录添加到 sys.path 中
sys.path.append(user_dir)
from debate_evidence_retriever import DebateEvidenceTool
from customize.get_ollama import GetOllama
r1 = GetOllama( model_type=1, model_name="llama3.1:latest")()

de_tool = DebateEvidenceTool(collection_name="knowledge_base", llm=r1).tool
from langgraph.prebuilt import create_react_agent
agent = create_react_agent(model=r1, tools=[de_tool],prompt="直接返回工具查询得到的结果，不要总结和解释。")
def print_stream(stream):
    for s in stream:
        message = s["messages"][-1]
        if isinstance(message, tuple):
            print(message)
        else:
            message.pretty_print()

inputs = {"messages": [("user", "中学生使用手机危害的实例")]}
print_stream(agent.stream(inputs, stream_mode="values"))